#ifndef __GZ_INTERFACE_LOADBALANCE_H__
#define __GZ_INTERFACE_LOADBALANCE_H__

#include <string>
#include <functional>

#include "MicroProxyMessage.pb.h"

namespace Gazella {
typedef std::function<void(bool, std::vector<MicroProxyMessage::ServiceRegister>)> loadbalance_callback_t;

class GzLoadBalance {
public:
    GzLoadBalance();
    ~GzLoadBalance();

    //select service register(s) from microproxy
    //if service_name empty, select all registers 
    //local means is or not local host service

    //async
    static int loadbalance(
        const std::string& service_name, 
        const std::string& if_name,
        MicroProxyMessage::ServiceTypeEnum service_type,
        loadbalance_callback_t callback,
        bool local = false,
        bool loadbalance = true, 
        uint32_t timeout = 3,
        int logic_groupid = 0, //specify the logic groupid, 0 means all group
        int domainid = -1 //specify the domainid of service interface, -1 means all domain
    );

    //sync
    static std::vector<MicroProxyMessage::ServiceRegister> loadbalance(
        const std::string& service_name, 
        const std::string& if_name,
        MicroProxyMessage::ServiceTypeEnum service_type,
        bool local = false,
        bool loadbalance = true, 
        uint32_t timeout = 3,
        int logic_groupid = 0, //specify the logic groupid, 0 means all group
        int domainid = -1 //specify the domainid of service interface, -1 means all domain
    );
};
} //namespace Gazella

#endif